package com.example.a22310.myapplication.Dailog;


import android.app.DialogFragment;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.example.a22310.myapplication.Activity.AddPost;

public class ImagesDialog extends DialogFragment {
    public ImagesDialog() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment

        View view = inflater.inflate(R.layout.dialog_choice_photo, container,
                false);
        Window win = getDialog().getWindow();
        WindowManager.LayoutParams lp = win.getAttributes();
        win.setGravity(Gravity.CENTER);
        lp.alpha = 0.9f;
        win.setAttributes(lp);


        TextView take_camera = (TextView) view.findViewById(R.id.camera_camera);
        take_camera.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                ((AddPost) getActivity()).takePictureInCamera();  //拍照
                ImagesDialog.this.dismiss();
            }

        });

        TextView take_picture = (TextView) view.findViewById(R.id.camera_phone);
        take_picture.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                ((AddPost) getActivity()).takePictureInAlbum();//从相册中选择
                ImagesDialog.this.dismiss();
            }

        });

        return view;
    }

}
